package com.sefonsoft.dataanalysis.service.impl.ssyj.cfaj;

import java.util.Map;

import org.jsoup.nodes.Document;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sefonsoft.dataanalysis.model.ssyj.cfaj.SsyjCfajXzcfajxxBean;
import com.sefonsoft.dataanalysis.service.impl.BaseService;
import com.sefonsoft.dataanalysis.service.model.Datas;
import com.sefonsoft.dataanalysis.utils.Tools;

/**
 * 行政处罚案件信息Service
 * @date 2017年12月11日11:24:10
 */
@Service
public class SsyjCfajXzcfajxxBeanService extends BaseService<SsyjCfajXzcfajxxBean> {

	@Override
	public Datas<SsyjCfajXzcfajxxBean> dataAnalysisByHtml(Document doc) {
		//Datas<SsyjCfajXzcfajxxBean> datas = new Datas<SsyjCfajXzcfajxxBean>();
		//TODO
		return null;
	}

	@Override
	public Class<SsyjCfajXzcfajxxBean> getTClass() {
		return SsyjCfajXzcfajxxBean.class;
	}
	
	@Override
	public void generateMap(Map<String, Object> map) {
		//作查询条件组装
		
	}
	
	@Override
	public Datas<SsyjCfajXzcfajxxBean> dataAnalysisByJson(String jsonStr) {
		SsyjCfajXzcfajxxBean scb = new SsyjCfajXzcfajxxBean();
		/**
		 * 做json特殊处理
		 */
//		jsonStr = jsonStr.replaceAll("null", "").replaceAll("\\t", "");
		JSONObject jsonobj = JSONObject.parseObject(jsonStr);
		JSONObject resultData = jsonobj.getJSONObject("resultData");
		JSONArray items = resultData.getJSONArray("items");
		JSONObject obj = items.getJSONObject(0);
		scb.setQyshmc(obj.getString("companyname"));
		scb.setZcdz(obj.getString("companysite"));
		scb.setFddbr(obj.getString("companyman"));
		scb.setSfzh(obj.getString("companymanid"));
		scb.setFzrxm(obj.getString("resp_man_id"));
		scb.setSfzh1(obj.getString("resp_man_id"));
		scb.setZjfzr(obj.getString("direct_person"));
		scb.setShxydm(obj.getString("idcode"));
		scb.setAjfl(obj.getString("toclassify"));
		scb.setAjmc(obj.getString("losecase"));
		scb.setXzcfjdwsh(obj.getString("punish_writ_num"));
		scb.setZywfss(obj.getString("losedetail"));
		scb.setCfyjhnr(obj.getString("punishway"));
		scb.setCfjg(obj.getString("punishunit"));
		scb.setCfsj(obj.getString("punishtime"));
		scb.setId(Tools.createUUID());
		return new Datas<SsyjCfajXzcfajxxBean>(scb);
	}
	
	@Override
	public Type getSourceType() {
		return Type.JSON;
	}

	
}
